import commonFun from '@/common/common.js'
const state = {
	token: "",
	userInfo: {}
}
const getters = {
	getAccessToken(state) {
		if(!state.token) {
			state.token = commonFun.getCookie('openid')
			console.log(111, state.token)
		}
		return state.token
	},
	getUserInfo(state) {
		if (Object.keys(state.userInfo).length <= 0) {
			let userInfo = uni.getStorageSync("userInfo")
			state.userInfo = userInfo || {}
		}
		return state.userInfo
	}
}
const mutations = {
	setUserInfo(state, item) {
		state.userInfo = item;
		uni.setStorageSync("userInfo", item)
	},
	logout(state) {
		state.token = ""
		state.userInfo = {}
		uni.removeStorageSync("userInfo")
	}
}
const actions = {
}
export default{
	namespaced:true,
	state,
	getters,
	mutations,
	actions
}